class ReadIni:
    def __init__(self, filename):
        try:
            self.cf = configparser.Configparser()
            self.cf.read(filename, encoding='utf-8')
        except Exception as e:
            raise e

    def getValue(self, sectionName, optionName):
        """
        读取ini文件某个节点的键和值
        """
        try:
            locator = self.cf.get(sectionName, optionName).split('>')
        except Exception as e:
            raise e
        else:
            return locator

    def getSection(self, sectionName):
        """
        获取某一个节点下面的所有的键和值
        """
        try:
            value = dict(self.cf.items(sectionName))    # 将获取到的值存放在字典value里面,不转化为字典的话本来是存放在列表里面的
        except Exception as e:
            raise else
        else:
            return value

    def getAllSections(self):
        """
        获取一个ini文件里面所有的节点
        """
        try:
            allSections = self.cf.sections()
        except Exception as e:
            raise e
        else:
            return allSections

    def getAllOptions(self, sectionName):
        """
        获取ini文件里面某一个节点下面所有的键
        """
        try:
            value = self.cf.options(sectionName)
        except Exception as e:
            raise e
        else:
            return value





















